class Solution:
    def reverse(self, x: int) -> int:
        n = str(x)
        if n[0] == '-':
            n = '-' + n[:0:-1]
        else:
            n = n[::-1]
        n = int(n)
        if n < -2**31 or n >= 2**31:
            return 0
        return n
    
if __name__ == '__main__':
    s = Solution()
    print(s.reverse(123))
    print(s.reverse(-123))
    print(s.reverse(120))
    print(s.reverse(0))
    print(s.reverse(1534236469))